import os

from auto_frame.base import Base
from selenium.webdriver.remote.webdriver import WebDriver
from page.member_operation import MemberOperation
from page.contact_page import ContactPage
from page.import_cantact_page import ImportContactPage
from data_file_analysis.yaml_analysis import YamlAnalysis as ya

class IndexPage(Base):

    #初始化driver
    def __init__(self,driver:WebDriver):
       super(IndexPage,self).__init__(driver)
       cur_path = os.path.abspath(os.path.dirname(__file__))  # 获取当前文件目录
       self.root_path = os.path.dirname(cur_path)
       self.step_path = f'{self.root_path}/steps/index_page.yaml'

    # 直接跳转至添加成员
    def add_member(self):
        self.steps(self.step_path, "goto_add_memnber")
        return MemberOperation(self.driver)

    #跳转到通讯录页面
    def goto_contact_page(self):
        self.steps(self.step_path,"goto_contact_page")
        return ContactPage(self.driver)

    #跳转到导入通讯录页面
    def goto_import_contact_page(self):
        self.steps(self.step_path, "goto_import_contact_page")
        return ImportContactPage(self.driver)